﻿<phone:PhoneApplicationPage
    x:Class="WPtrakt.CheckinHistory"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
     xmlns:lazy="clr-namespace:LazyListBox"
    xmlns:custom="clr-namespace:WPtrakt.Custom"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
    mc:Ignorable="d"
    shell:SystemTray.IsVisible="True" BackKeyPress="PhoneApplicationPage_BackKeyPress_1" OrientationChanged="PhoneApplicationPage_OrientationChanged_1">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <!-- Header-->
        <Grid.RowDefinitions>
            <RowDefinition Height="50"/>
            <RowDefinition Height="7"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid x:Name="TitlePanel" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Stretch">
            <Grid.RowDefinitions>
                <RowDefinition Height="50"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="50"/>
                <ColumnDefinition Width="80"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Image Grid.Row="0" Grid.Column="0" Source="/WPtrakt;component/Images/fulllogo.png" Height="40" Margin="10 0 5 0"/>
            <TextBlock Grid.Row="0" Grid.Column="1" CacheMode="BitmapCache"  Text="trakt"  FontSize="33" FontFamily="Segoe WP SemiBold"/>
        </Grid>
        <Border Grid.Row="1" Margin="0 2"  Height="3" Background="{StaticResource PhoneAccentBrush}" CacheMode="BitmapCache"/>
        <!-- Header end-->
        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="2" Margin="12,0,12,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <lazy:LazyListBox Grid.Row="2" Width="420" HorizontalAlignment="Left" ItemsSource="{Binding HistoryItems}" Name="HistoryList">
                <lazy:LazyListBox.ItemContainerStyle>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate>
                                    <ContentPresenter
                                            HorizontalAlignment="Stretch" 
                                            VerticalAlignment="Stretch" />
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </lazy:LazyListBox.ItemContainerStyle>
                <lazy:LazyListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel  Height="Auto" VerticalAlignment="Stretch"  >
                            <Grid Visibility="{Binding HeaderVisibility}" Margin="0 0 0 5" Background="{StaticResource PhoneAccentBrush}" Grid.Column="0" Grid.Row="0">
                                <TextBlock Margin="20 5" Foreground="White" FontSize="30"  Text="{Binding Header}"/>
                            </Grid>
                            <Grid Margin="0 5"  Tap="Grid_Tap_1" Height="Auto" VerticalAlignment="Stretch"  Name="ActivityGrid">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="100"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Image Opacity="0.3" Grid.Column="1" Source="Images/screen-small.jpg" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="-100 7" Height="68" MaxWidth="100" Stretch="Fill" Name="ScreenImage"  />
                                <Grid Grid.Column="2" Height="Auto">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"></RowDefinition>
                                        <RowDefinition Height="30"></RowDefinition>
                                    </Grid.RowDefinitions>
                                    <TextBlock Width="Auto" Height="Auto" Grid.Column="1" Grid.Row="0"  VerticalAlignment="Top"  HorizontalAlignment="Left"  TextWrapping="Wrap" Text="{Binding Activity}" Style="{StaticResource PhoneTextSubtleStyle}" Foreground="{StaticResource PhoneForegroundBrush}" />
                                    <TextBlock Grid.Column="1" Grid.Row="1" VerticalAlignment="Top"  HorizontalAlignment="Left" Height="Auto" TextWrapping="Wrap" Text="{Binding DateTimeString}" Style="{StaticResource PhoneTextSubtleStyle}" />
                                </Grid>
                                <toolkit:ContextMenuService.ContextMenu>
                                    <toolkit:ContextMenu>
                                        <toolkit:MenuItem Header="Rate" Name="HistoryRate" Click="HistoryRate_Click" />
                                    </toolkit:ContextMenu>
                                </toolkit:ContextMenuService.ContextMenu>
                            </Grid>
                        </StackPanel>
                    </DataTemplate>
                </lazy:LazyListBox.ItemTemplate>
                <lazy:LazyListBox.LoadedItemTemplate>
                    <DataTemplate>
                        <StackPanel  Height="Auto" VerticalAlignment="Stretch"  >
                            <Grid Visibility="{Binding HeaderVisibility}" Margin="0 0 0 5" Background="{StaticResource PhoneAccentBrush}" Grid.Column="0" Grid.Row="0">
                                <TextBlock Margin="20 5" Foreground="White" FontSize="30"  Text="{Binding Header}"/>
                            </Grid>
                            <Grid Margin="0 5"  Tap="Grid_Tap_1" Height="Auto" VerticalAlignment="Stretch"  Name="ActivityGrid">
                                <Grid.Triggers>
                                    <!--Show a nice animation to fade the minimal content into the full content-->
                                    <EventTrigger RoutedEvent="Grid.Loaded">
                                        <BeginStoryboard>
                                            <BeginStoryboard.Storyboard>
                                                <Storyboard>
                                                    <DoubleAnimation Storyboard.TargetName="ScreenImage" Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:0.6">
                                                        <DoubleAnimation.EasingFunction>
                                                            <PowerEase EasingMode="EaseIn" Power="3"/>
                                                        </DoubleAnimation.EasingFunction>
                                                    </DoubleAnimation>
                                                </Storyboard>
                                            </BeginStoryboard.Storyboard>
                                        </BeginStoryboard>
                                    </EventTrigger>
                                </Grid.Triggers>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="100"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Image Opacity="0.3" Grid.Column="1" Source="Images/screen-small.jpg" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="-100 7" Height="68" MaxWidth="100" Stretch="Fill"  />
                                <custom:DelayLoadImage Grid.Column="1" ActualImageSource="{Binding ScreenImage}" Name="ScreenImage" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="-100 7" Height="68" MaxWidth="100" Stretch="UniformToFill"  />
                                <Grid Grid.Column="2" Height="Auto">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"></RowDefinition>
                                        <RowDefinition Height="30"></RowDefinition>
                                    </Grid.RowDefinitions>
                                    <TextBlock Width="Auto" Height="Auto" Grid.Column="1" Grid.Row="0"  VerticalAlignment="Top"  HorizontalAlignment="Left"  TextWrapping="Wrap" Text="{Binding Activity}" Style="{StaticResource PhoneTextSubtleStyle}" Foreground="{StaticResource PhoneForegroundBrush}" />
                                    <TextBlock Grid.Column="1" Grid.Row="1" VerticalAlignment="Top"  HorizontalAlignment="Left" Height="Auto" TextWrapping="Wrap" Text="{Binding DateTimeString}" Style="{StaticResource PhoneTextSubtleStyle}" />
                                </Grid>
                                <toolkit:ContextMenuService.ContextMenu>
                                    <toolkit:ContextMenu>
                                        <toolkit:MenuItem Header="Rate" Name="HistoryRate" Click="HistoryRate_Click" />
                                    </toolkit:ContextMenu>
                                </toolkit:ContextMenuService.ContextMenu>
                            </Grid>
                        </StackPanel>
                    </DataTemplate>
                </lazy:LazyListBox.LoadedItemTemplate>
            </lazy:LazyListBox>
        </Grid>
    </Grid>
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="Images/appbar.refresh.rest.png" Text="Refresh" Click="ApplicationBarIconButton_Click_1" />
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
</phone:PhoneApplicationPage>